
const DB = require('../db/db');

module.exports = {
    // 新增就诊人
    async add(patientinfo) {
        let result = await DB.insert('patient', patientinfo)
        if (result.affectedRows > 0) {
            return { msg: '就诊人新增成功', code: 0, data: result };
        }
    },
    // 删除
    async del(patientinfo) {
        console.log(patientinfo);
        let result = await DB.del('patient', patientinfo)
        if (result.affectedRows > 0) {
            return { msg: '就诊人删除成功', code: 0, data: result };
        }
    },
    // 查询
    async select() {
        let result = await DB.select('patient', {});
        return { msg: '查询成功', code: 0, data: result };
    },
    // 通过姓名查询
    async selectbyname(param) {
        let result = await DB.select('patient', {
            fields: '*',
            where_and: [`name="${param.name}"`]
        });
        return { msg: '查询成功', code: 0, data: result };
    }
}